package io.github.topcatv.mall.common.ao;

import io.github.topcatv.mall.model.sys.entity.Role;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import org.springframework.cglib.beans.BeanCopier;

import java.io.Serializable;

/**
 * @author liuyi
 */
@Data
@Builder
@AllArgsConstructor
public class RoleAo implements Serializable {
    private static final BeanCopier ROLE_COPIER = BeanCopier.create(Role.class, RoleAo.class, false);
    private static final BeanCopier ENTITY_COPIER = BeanCopier.create(RoleAo.class, Role.class, false);
    private Integer id;
    private String name;

    public RoleAo() {
    }

    public RoleAo(Role role) {
        ROLE_COPIER.copy(role, this, null);
    }

    public Role toEntity() {
        Role role = new Role();
        ENTITY_COPIER.copy(this, role, null);
        return role;
    }
}
